package com.example.student.service;

import com.example.student.entity.Student;
import com.example.student.mapper.StudentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentService {
    @Autowired
    private StudentMapper studentMapper;

    public int delete(Integer id) {
        return studentMapper.delete(id);
    }

    public int save(Student student) {
        if (student.getId() == null) {
            return studentMapper.insert(student);
        }
        return studentMapper.update(student);
    }

    public Student getStudentById(Integer id) {
        return studentMapper.findById(id);
    }

    public List<Student> findAll(){
        return studentMapper.findAll();
    }
    public List<Student> findByIds(List<Long> id){
        return studentMapper.findByIds(id);
    }
}
